import 'package:casdon/modules/recipe/data/api/recipe_banner_list_api.dart';

class RecipeBannerModel {
  final String title;
  final String imageSrc;
  final String linkUrl;
  final int sort;

  RecipeBannerModel({
    required this.title,
    required this.imageSrc,
    required this.linkUrl,
    required this.sort,
  });

  // 静态方法转换
  static RecipeBannerModel fromApi(ResponseRecipeBannerListApi response) {
    return RecipeBannerModel(
      title: response.title,
      imageSrc: response.imageSrc,
      linkUrl: response.linkUrl,
      sort: response.sort,
    );
  }

  // 批量转换的静态方法
  static List<RecipeBannerModel> listFromApi(
    List<ResponseRecipeBannerListApi> items,
  ) {
    return items.map(fromApi).toList();
  }
}
